package com.hissy.controller;

import javax.servlet.http.HttpServletRequest;

import com.hissy.entity.emp.EmployeeVo;
import com.hissy.service.EmpService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

/**
 * Created by zhangyanfei on 2018/9/5.
 *
 * @author zhangyanfei
 * @date 2018/09/05
 */
@Controller
public class LoginController {
    @Autowired
    private EmpService empService;

    @RequestMapping("/")
    public String index() {
        return "redirect:login.htm";
    }

    @RequestMapping("login.htm")
    public String login() {
        return "login";
    }

    @RequestMapping("processLogin.htm")
    public String processLogin(Model model, EmployeeVo empVo, HttpServletRequest request) {
        //1.验证 2.放入会话中
        empVo.setId(1L);
        request.getSession().setAttribute("userSessionKey", empVo);
        model.addAttribute("empVo", empVo);
        return "index";
    }

    @RequestMapping("welcome.htm")
    public String welcome() {
        return "login/welcome";
    }
}
